home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / netzwerk / parnet / test / talk.c < prev   
C/C++ Source or Header  |  1996-02-26  |  1KB  |  64 lines

  1. /*
  2.  *  TALK.C
  3.  *
  4.  *  TALK addr port
  5.  *
  6.  *  Send continuous chatter to the specified port
  7.  */
  8.  
  9. #include "defs.h"
  10. #include <exec/types.h>
  11. #include <exec/io.h>
  12. #include <exec/ports.h>
  13. #include <libraries/dos.h>
  14. #include <devices/parnet.h>
  15.  
  16. typedef struct IORequest IOR;
  17.  
  18. IOParReq iob;
  19.  
  20. extern PORT *CreatePort();
  21.  
  22. int
  23. brk(void)
  24. {
  25.     return(0);
  26. }
  27.  
  28. void
  29. main(ac, av)
  30. int ac;
  31. char *av[];
  32. {
  33.     PORT *port = CreatePort(NULL, 0);
  34.     char buf[16];
  35.     int cnt = 0;
  36.  
  37.     onbreak(brk);
  38.     iob.io_Message.mn_ReplyPort = port;
  39.     iob.io_Addr = atoi(av[1]);
  40.     iob.io_Port = atoi(av[2]);
  41.     iob.io_Flags= PRO_DGRAM;
  42.  
  43.     if (OpenDevice("parnet.device", 0, (IOR *)&iob, 0)) {
  44.     printf("Unable to open parnet.device, error %d %d\n", iob.io_Error, iob.io_Actual);
  45.     exit(1);
  46.     }
  47.     printf("Device $%08lx Unit $%08lx\n", iob.io_Device, iob.io_Unit);
  48.     for (;;) {
  49.     if (SetSignal(0, SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F) & SIGBREAKF_CTRL_E)
  50.         break;
  51.     sprintf(buf, "%07ld\n", cnt++);
  52.     printf(buf);
  53.     iob.io_Command = CMD_WRITE;
  54.     iob.io_Data    = (APTR)buf;
  55.     iob.io_Length  = 8;
  56.     DoIO((IOR *)&iob);
  57.     printf("write %d error %d\n", iob.io_Actual, iob.io_Error);
  58.     }
  59.     CloseDevice((IOR *)&iob);
  60.     DeletePort(port);
  61. }
  62.  
  63.  
  64.